#  -*- coding: utf-8 -*-

from datetime import datetime

from pandas import DataFrame
from pymongo import ASCENDING
import time
from util.database import DB_CONN
from monitor.best_block_monitor import BestBlockMonitor
from monitor.momentum_monitor import MomentumMonitor

"""
监控子系统
"""


class MonitorModule:


    def monitoring(self,begin_date=None,end_date=None):
        # 所有的因子实例
        monitor_items = [
            # PEFactor(),
            MomentumMonitor()
        ]

        now = datetime.now().strftime('%Y-%m-%d')
        if begin_date is None:
            begin_date = "1995-02-24"
        if end_date is None:
            end_date = now
        for item in monitor_items:
            start_time = time.time()

            item.monitoring(begin_date=begin_date, end_date=end_date)
            end_time = time.time()
            print('计算监控数据：%s, 从日期：%s 到 %s  ，共耗时：%.3f 秒' % (item.name, begin_date, end_date, (end_time - start_time)), flush=True)
